#include "mylabel.h"
#include <QTextCodec>
#include <QDebug>
myLabel::myLabel(QWidget *parent) : QLabel(parent)
{
    filename.clear();
    isfull=false;
    //开启鼠标附属功能
    this->setAcceptDrops(true);
}


void myLabel::dragEnterEvent(QDragEnterEvent *event)
{
    QString filename = event->mimeData()->text();
    if(filename.isEmpty())
    {
        return;
    }
    else
    {
        if(filename != this->filename) //当前filename 不等于 全局的 filename
        {
            this->filename = filename;
            event->accept();  //结束当前事件
        }
    }
}


void myLabel::dropEvent(QDropEvent *)
{
    if(this->filename.isEmpty())
    {
        return;
    }
    this->filename.replace("file://","");
    this->filename.replace("\r\n","");
    //qDebug()<<filename;
    emit SignalSendPlayPath(this->filename);
    this->filename.clear();
}
void myLabel::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(isfull)
    {
        isfull=false;
        emit SignalSendfullwin(isfull);
    }
    else
    {
        isfull=true;
        emit SignalSendfullwin(isfull);
    }
}




